<template>
  <div class="detailWrap" :style="'background-image:url('+ product.picture +')'">
    <div class="main w" v-show="product.picture">
      <h1>{{product.title}}</h1>
      <div class="content">
        <div class="detail">
          <p class="info">{{product.description}}</p>
        </div>
        <div class="more" @click="handleToMore">
          <img src="imgs/btn.png" alt />
          <p>{{$t('vr.moreBtn')}}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import api from 'servicePath/index'
import { mapState, mapMutations } from 'vuex'
export default {
  data() {
    return {
      product: {}
    }
  },
  computed: {
    ...mapState(['lang', 'userInfo'])
  },
  watch: {
    lang() {
      if (this.userInfo) {
        this.handleProductDetail()
      } else {
        this.isShowLogin('show')
      }
    }
  },
  mounted() {
    // 判断用户是否登录
    if (this.userInfo) {
      this.handleProductDetail()
    } else {
      this.isShowLogin('show')
    }
  },
  methods: {
    ...mapMutations(['isShowLogin']),
    // 点击更多
    handleToMore() {
      this.$router.push({
        path: `/fakuma/pc/industry/list/${this.product.id}`
      })
    },
    // 根据锚点获取行业详情
    async handleProductDetail() {
      const params = {
        anchor: this.$route.params.anchorId,
        language: this.lang
      }
      const res = await api.getIndustryByAnchor(params)
      this.product = res.data || {}
    }
  }
}
</script>

<style lang="scss" scoped>
.detailWrap {
  background-size: cover;
  min-height: calc(100vh - 90px);
  padding-bottom: 30px;
  background-color: #f5f5f5;
  .main {
    padding-top: 50px;
    h1 {
      color: #fff;
      margin-top: 30px;
      margin-bottom: 10px;
      padding-left: 30px;
      font-weight: 400;
    }
    .content {
      display: flex;
      justify-content: space-between;
      align-items: center;
      background: #fff;
      padding: 40px 80px 40px 60px;
      height: 280px;
      border-radius: 16px;
      opacity: 0.79;
      .detail {
        flex: 1;
        min-height: 200px;
        // .info:first-letter {
        //   font-size: 2.5em;
        //   text-transform: uppercase;
        // }
        .info {
          // word-break: break-all;
          line-height: 28px;
          font-size: 18px;
        }
      }
      .more {
        width: 140px;
        text-align: center;
        margin-left: 100px;
      }
    }
  }
}
</style>